USE [Training]
GO

IF NOT EXISTS (SELECT * from dbo.sysobjects WHERE id = OBJECT_ID(N'dbo.training_api_TrainingRecordInsert'))
	EXEC('CREATE PROC dbo.training_api_TrainingRecordInsert AS')
GO

ALTER PROC dbo.training_api_TrainingRecordInsert
	@EmployeeID			int,
	@DueDate			datetime,
	@CompletedDate		datetime = null,
	@SkillID			int,
	@TrainingRecordID	int output
AS
	INSERT INTO TrainingRecord(
		EmployeeID,
		DueDate,
		CompletedDate,
		SkillID,
		LastModified)
	VALUES(
		@EmployeeID,
		@DueDate,
		@CompletedDate,
		@SkillID,
		GETDATE())
	SELECT @TrainingRecordID = SCOPE_IDENTITY()

